<template>
  <div id="voice_detail">
    <c-title :hide="false" :text="'音频详情'"></c-title>
    <div id="content" v-if="isShow === 1">
      <div class="topA">{{ dataInfo.title }}</div>
      <div class="voice-detail-top">
        <span class="author">{{ dataInfo.author }}</span>
        <span class="voice-created-at">{{ dataInfo.created_at }}</span>
      </div>
      <div class="content_a">
        <div class="audio-wrapper">
          <audio id="audio" ref="audio" @pause="onPause" @play="onPlay" @timeupdate="onTimeupdate"
            @loadedmetadata="onLoadedmetadata" controls="controls" style="display: none;" :src="dataInfo.audio_link">
            <!--<source-->
            <!--:src="dataInfo.audio_link"-->
            <!--type="audio/mp3">-->
            您的浏览器不支持 audio 标签！
          </audio>
          <div style="flex:1;display: flex;align-items: center;justify-content: space-around;">
            <div class="time_left">{{ audio.currentTime | formatSecond }}</div>
            <div class="slider" :ref="`slidre` + i" @touchstart="handleTouchStart($event, i)">
              <div class="slider-track"></div>
              <div class="slider-fill" :style="'width:' + (sliderTime >= 100 ? 100 : sliderTime) + '%'"></div>
              <div class="slider-thumb" :style="'left:' + (sliderTime >= 100 ? 100 : sliderTime) + '%'"></div>
            </div>
            <div class="time_right">{{ audio.maxTime | formatSecond }}</div>
          </div>
          <div class="audio-left" v-if="readyState > 0">
            <i @click="startPlayOrPause" v-if="isPlay && readyState > 0" class="iconfont icon-play"></i>
            <i @click="startPlayOrPause" v-if="!isPlay && readyState > 0" class="iconfont  icon-pause"></i>
          </div>
          <img class="audio-left-img" v-else src="../../../../assets/images/loading.gif" />
        </div>
      </div>
      <div class="content_b">
        <div class="text" v-html="dataInfo.content"></div>
      </div>
      <div class="foot_advs" @click="toAdvs()" v-if="is_advs_type">
        <p class="advs_title">{{ dataInfo.advs_title }}</p>
        <div class="advs_img_bg" v-if="dataInfo.advs_img">
          <img class="advs_img" :src="dataInfo.advs_img" />
        </div>
        <div class="advs_img_bg" v-if="!dataInfo.advs_img">
          <img class="advs_img" src="@/assets/images/img_default.png" />
        </div>
        <div class="advs_desc">{{ dataInfo.advs_title_footer }}</div>
      </div>


      <div class="content_c" v-if="codeUrl">
        <div class="code">
          <div class="img">
            <img :src="codeUrl" />
          </div>
          <span>长按识别二维码</span>
        </div>
      </div>
      <div class="foot">
        <div class="read">阅读 {{ read_num }} </div>
        <div class="foot-right">
          <div v-if="is_report_enabled" class="report" @click="report()">
            <i class="iconfont icon-report"></i>
            <span>举报</span>
          </div>
          <div v-if="is_link" class="link" @click="link()">阅读原文</div>
        </div>
      </div>

      <!-- 评论 -->
      <div class="comment" v-if="comment">
        <div class="comment-title">评论详情</div>
        <div class="commentList">
          <template v-if="commentList && commentList.length !== 0">
            <div class="firstComment" v-for="(item, ind) in commentList" :key="ind" @click.stop="delComment(item, ind)">
              <div class="userTop">
                <div style="display: flex;align-items: center;">
                  <div class="user-image">
                    <img :src="item.head_image" alt="" />
                  </div>
                  <div class="nick-name">{{ item.nick_name }}</div>
                </div>
                <div class="user">
                  <div class="contenBox">
                    <div class="txt">{{ item.content }}</div>
                    <div class="contenImg" v-if="item.comment_images.length > 0"
                      @click.stop="watchImg(item.comment_images)">
                      <img :src="item.comment_images" alt="" />
                    </div>
                  </div>
                  <div style="display: flex;align-items: center;justify-content: space-between;">
                    <div class="created-at">{{ item.created_at }}</div>
                    <div class="reply" @click.stop="replyBtn(item.nick_name, item, ind)">回复</div>
                  </div>
                </div>
              </div>
              <!-- 回复的评论 -->
              <div class="commentLis" v-show="item.child" v-for="(info, index) in item.child" :key="index"
                @click.stop="delComment(info, ind, index, 'child')">
                <div class="commentLis-user-top">
                  <div style="display: flex;align-items: center;">
                    <div class="image">
                      <img :src="info.head_image" alt="" v-if="info.head_image" />
                      <img src="../../../../assets/images/photo-mr.jpg" alt="" v-else />
                    </div>
                    <div class="user-name">{{ info.nick_name }}</div>
                  </div>
                  <div class="commentLis-user">
                    <div class="contenBox">
                      <div style="text-align: left;padding-left: 2.0625rem;margin-bottom: 0.3125rem;" class="txt" v-if="info.reply_id != '0' || info.reply_name">回复{{ info.reply_name }}:</div>
                    <div class="commentLis-user-content">{{ info.content }}</div>
                      <div class="commentLis-user-img" v-show="info.comment_images"
                        @click.stop="watchImg(info.comment_images)">
                        <template v-for="(datas, indkey) in info.comment_images">
                          <img :src="datas" :key="indkey" />
                        </template>
                      </div>
                    </div>
                  </div>
                  <div class="commentLis-user-bottom">
                    <div class="dateDay">{{ info.updated_at }}</div>
                    <div class="reply" @click.stop="replyBtn(info.nick_name, info, ind)">回复</div>
                  </div>
                </div>
              </div>
              <!-- 展开更多 加在更多评论 -->
              <div class="commentLis" v-if="item.reply_num > 0 && item.commentShow">
                <div class="commentMore" @click.stop="moreCommentLis(item.id, ind)">
                  显示展开{{ item.reply_num }}条回复
                  <van-icon name="arrow-down" />
                </div>
              </div>
            </div>
            <div class="commentMore" v-if="commentPage < last_page" @click="getMore">
              展开更多的评论
              <van-icon name="arrow-down" />
            </div>
          </template>
          <template v-else>
            <div class="no-comment">暂无评论</div>
          </template>
        </div>
        <!-- 回复输入框 -->
        <div class="replyInp" :class="{'w375': fun.isPc()}">
          <div class="inpNav" @click="subMainCommentBtn">
            <input :disabled="showCommentInput"  type="text" placeholder="来都来了，留下点什么吧" />
          </div>
          <div class="replyInp-right">
            <div @click="like(like_num)">
              <i :class="is_liked ? 'iconfont icon-zb_like' : 'iconfont icon-dianzan'"></i>
              <span>{{ like_num }}</span>
            </div>
            <div>
              <i class="iconfont icon-comment"></i>
              <span>{{ commentNum }}</span>
            </div>
          </div>
        </div>
        <yz-comment-input v-model="showCommentInput" v-on:confirm="subMainBtn" :options="commentInputOptions"  :openImg="false">
          <!-- <div class="commentInput-slot-style" v-if="commentInputOptions.type == 'reply'">
            回复<span class="selcolor">@{{ replyName }}</span>
          </div> -->
        </yz-comment-input>
      </div>
      <van-image-preview v-model="showImg" :images="imgList" :start-position="imgStart"></van-image-preview>
    </div>
  </div>
</template>

<script>
import voice_detail_controller from "./voice_detail_controller";

export default voice_detail_controller;
</script>

<style lang="scss" rel="stylesheet/scss" scoped>

.w375{
  width: 375px;
  position: fixed;
  left: 50% !important;
  transform: translateX(-50%) !important;
}

.commentMore {
  font-size: 0.81rem;
  color: #4d88df;
  display: flex;
  justify-content: center;
  align-items: center;
}
.voice-detail-top {
  margin-top: 0.8438rem;
  margin-bottom: 1.5625rem;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;

  .voice-created-at {
    font-size: 0.8125rem;
    font-weight: 400;
    color: #AAAAB3;
  }

  .author {
    color: #6E6E79;
    font-size: 0.875rem;
    margin-right: 0.625rem;
  }
}

.comment {
  background-color: #fff;
  // padding-bottom: 1.94rem;
  padding: 1rem;

  .replyInp-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;

    .icon-dianzan,
    .icon-comment {
      margin-right: 0.4063rem;
    }

    .icon-zb_like {
      color: #F15353;
    }

    .icon-comment {
      margin-left: 1.125rem;
    }
  }

  .replyInp {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: 3.13rem;
    background-color: #fff;
    border-top: 1px solid #F0F0F1;
    padding-left: 0.9375rem;
    padding-right: 0.875rem;
    display: flex;
    align-items: center;

    .userImg {
      width: 2.19rem;
      height: 2.19rem;
      border-radius: 100%;

      img {
        width: 2.19rem;
        height: 2.19rem;
        border-radius: 100%;
      }
    }

    .inpNav {
      // flex: 1;
      width: 12.5rem;
      height: 1.88rem;
      background: #f5f5f5;
      border-radius: 0.94rem;
      padding-left: 0.97rem;
      // margin-left: 0.66rem;
      z-index: 5;

      input {
        width: 100%;
        height: 100%;
        outline: none;
        border: none;
      }
    }
  }

  .title {
    font-size: 1rem;
    color: #202020;
    text-align: left;
    padding-top: 1.06rem;
    padding-left: 0.97rem;
    padding-bottom: 1.16rem;
    box-sizing: border-box;
  }
  .no-comment{
    color:#AAAAB3;
    margin-top: 1.875rem;
    margin-bottom: 7.7188rem;
  }
  .comment-title {

    border-top: 1px solid #F0F0F1;
    font-size: 1.125rem;
    color: #00001C;
    font-weight: bold;
    padding: 1.4375rem 0 0;
    text-align: left;
  }

  .nick-name {
    font-size: 0.8125rem;
    font-weight: 400;
    color: #6E6E79;
  }

  .user-image {
    width: 2rem;
    height: 2rem;
    margin-right: 0.5625rem;

    img {
      width: 100%;
      height: 100%;
      border-radius: 100%;
    }
  }

  .commentList {
    padding: 1.13rem 0 4rem;

    .commentLis-user-img {
      padding-left: 2.0625rem;
      display: flex;
      align-items: center;
      flex-wrap: wrap;

      img {
        width: 3rem !important;
        height: 3rem !important;
        background-color: #c1c1c1;
        border-radius: 0.13rem;
        margin: 0;
        margin-right: 0.25rem;
        border-radius: 0 !important;
      }
    }

    .created-at {

      color: #AAAAB3;
      font-size: 0.75rem;
      font-weight: 400;
    }

    .firstComment {
      .userTop {
        // display: flex;

        .user {
          text-align: left;
          padding-left: 2.5625rem;
          height: 100%;

          .userName {
            font-size: 1rem;
            color: #2e2e2e;
          }

          .dateDay {
            font-size: 0.63rem;
            color: #767676;
          }

          .contenBox {
            padding: 0 !important;
            margin-bottom: 0.625rem;
            width: 100%;

            .txt {
              font-size: 0.875rem;
              color: #2e2e2e;
              display: flex;
            }

            .contenImg {
              display: flex;
              justify-content: flex-start;

              img {
                width: 3rem;
                height: 3rem;
                background-color: #c1c1c1;
                border-radius: 0.13rem;
                margin: 0;
                margin-right: 0.25rem;
              }
            }
          }
        }

        .image {
          width: 2.5rem;
          height: 2.5rem;
          background-color: #b5b5b5;
          border-radius: 50%;
          margin-right: 0.63rem;

          img {
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 50%;
          }
        }

        .reply {
          font-size: 0.6875rem;
          letter-spacing: 0.02rem;
          color: #00001C;
          background: #F0F0F1;
          border-radius: 0.9063rem;
          width: 2.375rem;
          height: 1.25rem;
          text-align: center;
          line-height: 1.25rem;
        }
      }

      .commentLis-user-content {
        text-align: left;
        padding-left: 2.0625rem;
        font-size: 0.875rem;
        font-weight: 400;
        color: #00001C;
      }

      .commentLis-user-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-left: 2.0625rem;

        .dateDay {
          color: #AAAAB3;
          font-size: 0.75rem;
        }

        .reply {
          width: 2.375rem;
          text-align: center;
          height: 1.25rem;
          line-height: 1.25rem;
          background: #F0F0F1;
          border-radius: 0.9063rem;
          font-size: 0.6875rem;
        }
      }

      .commentLis-user-top {
        img {
          width: 1.5rem;
          height: 1.5rem;
          border-radius: 100%;
        }

        .user-name {
          font-size: 0.8125rem;
          font-weight: 400;
          color: #818181;
          margin-left: 0.5625rem;
        }
      }

      .commentLis {
        margin-top: 0.94rem;
        margin-left: 2.5625rem;

        .userTop {
          display: flex;

          .user {
            flex: 1;
            text-align: left;
            height: 100%;

            .userName {
              font-size: 0.88rem;
              color: #2e2e2e;
            }

            .dateDay {
              font-size: 0.63rem;
              color: #767676;
            }

            .contenBox {
              margin-top: 0.88rem;
              width: 100%;

              .txt {
                font-size: 0.88rem;
                color: #2e2e2e;
                margin-bottom: 0.63rem;
              }

              .contenImg {
                display: flex;
                justify-content: flex-start;

                img {
                  width: 3rem;
                  height: 3rem;
                  background-color: #c1c1c1;
                  border-radius: 0.13rem;
                  margin: 0;
                  margin-right: 0.25rem;
                }
              }
            }
          }

          .image {
            width: 1.88rem;
            height: 1.88rem;
            background-color: #b5b5b5;
            border-radius: 50%;
            margin-right: 0.63rem;

            img {
              width: 1.88rem;
              height: 1.88rem;
              border-radius: 50%;
            }
          }

          .reply {
            font-size: 0.69rem;
            line-height: 1.27rem;
            letter-spacing: 0.02rem;
            color: #f15353;
          }
        }
      }
    }
  }
}

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 1rem;
  background-color: #fff;

  .foot-right {
    display: flex;
    align-items: center;
  }

  h4 {
    text-align: left;
    font-size: 18px;
  }

  h4.like {
    float: left;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }

  .read {
    padding-right: 0.625rem;
    color: #AAAAB3;
    text-align: left;
    font-size: 0.875rem;
  }

  .report,
  .link {
    padding-right: 0.625rem;
    color: #AAAAB3;
    font-size: 0.875rem;
  }

  .report {
    display: flex;
    align-items: flex-end;

    .icon-report {
      margin-right: 0.125rem;
    }
  }

  h4.copy {
    padding-right: 0.625rem;
    float: left;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }
}



.foot_advs {
  padding: 1rem;
  margin-bottom: 1.25rem;
  height: auto;
  background: #fff;
  width: 100%;
  border-radius: 0;

  .advs_img_bg {
    width: 100%;
    margin-top: 1rem;
    margin-bottom: 1.7813rem;
    border-radius: 0.75rem;
    overflow: hidden;
  }

  .advs_img {
    width: 100%;
  }

  .advs_desc {
    text-align: left;
    font-size: 1rem;
    color: #00001C;
  }

  p.advs_title {
    text-align: left;
    height: 1.875rem;
    line-height: 1.875rem;
    font-size: 1rem;
    font-weight: 400;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

#voice_detail {
  background: #fff;

  .topA {
    padding: 0.8125rem 1rem 0;
    font-size: 1.25rem;
    text-align: left;
    font-weight: bold;
  }

  #content {
    .content_a {
      background: #fff;
      padding-bottom: 0.625rem;

      .banner {
        width: 100%;
        height: auto;
        overflow: hidden;
        background: #f5f5f5;

        img {
          width: 100%;
          height: auto;
        }
      }






      .audio-wrapper {
        width: 21.5625rem;
        height: 3.75rem;
        border-radius: 0.75rem;
        background-color: #F5F5F5;
        display: flex;
        align-items: center;
        margin: 0.3125rem auto;
        color: #3e3e3e;
        padding: 0 0.8438rem 0 0.9375rem;
        box-sizing: border-box;
      }

      .audio-left {
        text-align: center;
        flex-shrink: 0;
        width: 1.9375rem;
        height: 1.9375rem;
        line-height: 1.9375rem;
        border-radius: 100%;
        border: 1px solid #AAAAB3;
      }

      .audio-left-img {
        width: 40px;
        position: relative;
        // top: 15px;
        margin: 0;
        display: initial;
        /* 解除与app的样式冲突 */
        cursor: pointer;
      }

      .slider {
        width: 11.25rem;
        position: relative;
        height: 30px;
        margin: 0 0.625rem;
        display: flex;
        align-items: center;
        cursor: default;
        user-select: none;
        outline: none;
        // overflow: hidden;
      }

      .slider-track {
        position: absolute;
        height: 2px;
        left: 0;
        right: 0;
        top: 50%;
        margin-top: -1px;
        background-color: #bec2c1;
      }

      .slider-fill {
        position: absolute;
        height: 2px;
        width: 100%;
        background-color: #3B3B4A;
        left: 0;
        top: 50%;
        margin-top: -1px;
      }

      .slider-thumb {
        position: absolute;
        top: 50%;
        width: 12px;
        height: 12px;
        background: #FFFFFF;
        box-shadow: 0px 3px 10px 1px rgba(0, 0, 0, 0.16);
        color: #28a4e9;
        border-radius: 50%;
        transform: translate(-50%, -50%);
        cursor: pointer;
      }

      .time {
        display: flex;
      }

      .time_left {
        flex: 1;
        text-align: left;
        font-size: 0.75rem;
        color: #3B3B4A;
      }

      .time_right {
        flex: 0 0 3rem;
        padding-right: 0.6875rem;
        color: #3B3B4A;
        font-size: 0.75rem;
      }
    }

    .content_b {
      background: #fff;
      margin-top: 0.625rem;

      h2 {
        height: 2.5rem;
        line-height: 2.5rem;
        font-size: 16px;
        display: flex;
        justify-content: space-between;
        padding: 0 0.875rem;

        span {
          font-size: 14px;
          color: #8c8c8c;
          font-weight: normal;
        }
      }

      .text {
        padding: 0.625rem 1.25rem;
        text-align: left;
        font-size: 14px;
        color: #666;
      }
    }

    .content_c {
      background: #fff;
      margin-top: 0.625rem;
      padding-bottom: 1.25rem;

      h3 {
        height: 2.5rem;
        line-height: 2.5rem;
        font-size: 16px;
        text-align: left;
        padding: 0 0.875rem;
      }

      .code {
        span {
          color: #8c8c8c;
        }

        .img {
          width: 7.5rem;
          height: 7.5rem;
          overflow: hidden;
          background: #f5f5f5;
          margin: 0.625rem auto;

          img {
            width: 100%;
          }
        }
      }
    }
  }
}</style>
<style lang="scss" rel="stylesheet/scss">#voice_detail {
  img {
    display: block;
    max-width: 100% !important;
    height: auto !important;
  }

  iframe {
    width: 100% !important;
  }

  li {
    list-style: inherit;
  }
}</style>